package com.xherorlclass;

import com.xherorlclass.channelHandler.ConsumerChannelInitializer;
import com.xherorlclass.channelHandler.handler.MySimpleChannelInboundHandler;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;

/**
 * 提供bootstrap单例
 * @author Xherorl
 * @createTime 2023-08-24 10:54
 *
 */
@Slf4j
public class NettyBootstrapInitializer {
    
    private static final Bootstrap bootstrap = new Bootstrap();
    // 建立一个新的channel
//    private static NioEventLoopGroup group = new NioEventLoopGroup();
    
    static {
        NioEventLoopGroup group = new NioEventLoopGroup();
        bootstrap.group(group)
            // 选择初始化一个什么样的channel
            .channel(NioSocketChannel.class)  // 实例化一个Channel
            // 选择初始化一个什么样的channel
            .handler(new ConsumerChannelInitializer());
    }
    
    private NettyBootstrapInitializer() {
    }
    
    public static Bootstrap getBootstrap() {

        return bootstrap;

    }
}
